package app.dev.telemetric.server;
import java.util.Date;
import java.util.concurrent.Semaphore;

import org.springframework.context.ApplicationContext;

import app.dev.telemetric.dao.StreamDataMapper;
import app.dev.telemetric.model.StreamData;


public class consultor extends Thread {
	StreamDataMapper dMapper;
	public long total_time=0;
	long id;
	Semaphore s;
	
	public consultor(ApplicationContext ac, long base)
	{
		dMapper=ac.getBean("streamDataMapper", StreamDataMapper.class);
		id=base;
		this.setName("consultor "+id);
		//System.out.println(id);
		s=ac.getBean("waitPoolLevel", Semaphore.class);
	}
	
	public void run()
	{
		long uno=new Long(1);
		StreamData d;
		long time;
		
		for(int i=0; i<100; i++)
		{
			d=new StreamData();
			id++;
			d.setIdApplication(uno);
			d.setIdDevice(uno);
			d.setIdProtocol(uno);
			d.setTimestampMl(new Date());
			time=System.nanoTime();
			dMapper.insert(d);
			//s.release();
			time=System.nanoTime()-time;
			total_time+=time;
		}
	}

}
